package cz.data.common.support.metadata;

import cz.data.common.support.DataTypeEnum;

public enum SqlserverDataTypeEnum implements DataTypeEnum {

    VARCHAR("varchar", "变长字符串"),
    NVARCHAR("nvarchar", "短变长字符串"),
    CHAR("char", "定长字符串"),
    NCHAR("nchar", "短定长字符串"),
    TEXT("text", "长文本"),
    TINYINT("tinyint", "tinyint整型"),
    SMALLINT("smallint", "smallint整型"),
    INT("int", "int整型"),
    DECIMAL("decimal", "定点数"),
    FLOAT("float", "单精度小数"),
    DATETIME("datetime", "datetime日期"),
    TIMESTAMP("timestamp", "时间戳日期"),
    BINARY("binary", "定长二进制"),
    VARBINARY("varbinary", "变长二进制"),
    IMAGE("image", "image变长二进制")
    ;


    private final String value;
    private final String title;

    SqlserverDataTypeEnum(String value, String title) {
        this.value = value;
        this.title = title;
    }

    public String getValue() {
        return value;
    }

    public String getTitle() {
        return title;
    }

    public static SqlserverDataTypeEnum match(String value, SqlserverDataTypeEnum defaultItem) {
        if (value != null) {
            for (SqlserverDataTypeEnum item: SqlserverDataTypeEnum.values()) {
                if (item.getValue().equalsIgnoreCase(value)) {
                    return item;
                }
            }
        }
        return defaultItem;
    }
}
